/** @format */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { injectable } from 'inversify';
import 'reflect-metadata';
import log4js from 'log4js';
const loglevel = process.env.LOG_LEVEL ? process.env.LOG_LEVEL : 'debug';
export interface ILogger {
  error(error: any): void;
  warn(warn: any): void;
  info(info: any): void;
  debug(debug: any): void;
}
log4js.configure({
  appenders: {
    proposal_web: { type: 'console' },
    fileout: {
      type: 'dateFile',
      filename: './logs/debug.log',
      pattern: 'debug-yyyy-MM-dd.log',
      alwaysIncludePattern: true,
    },
  },
  categories: {
    default: { appenders: ['fileout', 'proposal_web'], level: loglevel },
  },
});
export const logger = log4js.getLogger('proposal_web');

@injectable()
export class WebLogger implements ILogger {
  error(error: any): void {
    logger.error(error);
  }

  warn(warn: any): void {
    logger.warn(warn);
  }

  info(info: any): void {
    logger.info(info);
  }

  debug(debug: any): void {
    logger.debug(debug);
  }
}
